﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web;

namespace BIZ
{
    public class DomainConfirmationFilter : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string SERVER_NAME = HttpContext.Current.Request.ServerVariables["SERVER_NAME"] == null ? "" : HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString().ToLower().Replace("www.", "");
            if (SERVER_NAME != System.Configuration.ConfigurationSettings.AppSettings["serverName"])
            {
                string url = "/share/norright.html";
                Redirect(url);
            }

        }
        public static void Redirect(string url)
        {
            ScriptKit.WriteScript("window.top.location.href=\"" + url + "\";");
            if (null != HttpContext.Current)
            {
                HttpContext.Current.Response.End();
            }
        }
    }
}
